package com.nebula.maven.springbootmebula.beetl;

import com.nebula.maven.springbootmebula.demos.web.User;
import com.nebula.maven.springbootmebula.nebula.NebulaResult;
import com.nebula.maven.springbootmebula.nebula.NebulaTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class NebulaImpl implements UserMapper{

    @Autowired
    BeetlTextRender beetlTextRender;

    @Autowired
    NebulaTemplate nebulaTemplate;

    public NebulaResult<User> queryUser(String name) {
        Map<String, Object> params = Map.of(
                "name", name);
        String queryNql = beetlTextRender.resolve("queryUser", params);
        return nebulaTemplate.queryObject(queryNql, User.class);
    }
}
